package config

import (
	"fmt"
	"gopkg.in/yaml.v3"
	"os"
)

var (
	Cfg Configuration
)

type Configuration struct {
	DSN       string `yaml:"dsn"`
	Token     string `yaml:"token"`
	JwtSecret string `yaml:"jwtSecret"`
	Log       Log    `yaml:"log"`
}
type Log struct {
	Level string `yaml:"level"`
}

func LoadConfig(filePath string) (*Configuration, error) {
	content, _ := os.ReadFile(filePath)
	err := yaml.Unmarshal(content, &Cfg)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println("config file:", Cfg)
	return &Cfg, nil
}
